package cn.tx.customer;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author Mxb
 * @version 1.0
 * @date 2020/10/4 10:06
 */
@Component
public class TopCustomer {
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,
                    key = {"user.*"},
                    exchange = @Exchange(type = "topic", name =
                            "topics")
            )
    })
    public void receive1(String message) {
        System.out.println("消费者【1】接收到message: " + message);
    }

    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,
                    key = {"user.#"},
                    exchange = @Exchange(type = "topic", name =
                            "topics")
            )
    })
    public void receive2(String message) {
        System.out.println("消费者【2】接收到message: " + message);
    }
}
